package org.eliza.base.basicx.controlflowx


private fun basic() {
//    接收 if返回值
    var ii = if (kotlin.random.Random(12).nextInt() >= 0) { //() 必须
        println("run")
        1
    } else {
        2
    }

    val intRange = 0 until 8
    if (kotlin.random.Random(10).nextInt() in intRange) {
        println("in range")
    }
    if (kotlin.random.Random(10).nextInt() !in intRange) {
        println("in range")
    }

}

private fun whenx() {

//    接收 if返回值
    val nextInt = kotlin.random.Random(10).nextInt()
    when (nextInt) {
        1, 2 -> println("one") //多值
        3 -> println("three")  //单值
        in 4..6 -> println("4~6") //范围
        !in 4..6 -> println("!(4!6)")
        is Int -> println("is Int")  //类型
        else -> println("other")
    }

    when {
        nextInt in 0 until 10 -> println("in 10") // 判断表达式
        nextInt > 5 -> println("in 5")
        nextInt in setOf(1, 2, 3) -> println("in setOf")
        else -> println("else")
    }
}

private  fun main() {


}